package edu.qhst.resource.service;

import edu.qhst.resource.dto.UploadRespDto;
import io.minio.StatObjectResponse;
import io.minio.errors.*;
import io.minio.messages.Bucket;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Optional;

/**
 * minio服务接口
 *
 * @author 加浓美式
 * @Date 2023/6/26
 */
public interface MinioService {
    void createBucket() throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException;

    UploadRespDto uploadFile(MultipartFile file, String bucketName) throws Exception;

    List<Bucket> getAllBuckets() throws Exception;

    Optional<Bucket> getBucket(String bucketName) throws IOException, InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException, InvalidResponseException, InternalException, ErrorResponseException, ServerException, XmlParserException, ServerException;

    void removeBucket(String bucketName) throws Exception;

    String getObjectURL(String bucketName, String objectName, Integer expires) throws Exception;

    InputStream getObject(String bucketName, String objectName) throws Exception;

    void putObject(String bucketName, String objectName, InputStream stream) throws Exception;

    void putObject(String bucketName, String objectName, InputStream stream, long size, String contextType) throws Exception;

    StatObjectResponse getObjectInfo(String bucketName, String objectName) throws Exception;

    void removeObject(String bucketName, String objectName) throws Exception;

    UploadRespDto uploadVideo(MultipartFile file, String bucketName) throws Exception;
}
